from django.conf import settings
from django.contrib.auth.models import User
from django.db import models
from django.utils.translation import ugettext_lazy as _
from opinion_extractor.temporal_model.models import TemporalModel


# TODO: Raise an NotARespondentException on save if the user doesn't have the questionnaire.answer_questionnaire permission
class AbstractRespondent(TemporalModel):
    min_days_between_versions = settings.OPINION_EXTRACTOR[
        'min_days_between_respondent_profile_changes'
    ]
    unchangeable_fields = ['user',]
    
    user = models.ForeignKey(
        User,
        verbose_name=_('user'),
        related_name='respondent_profiles',
        editable=False
    )
    
    class Meta(TemporalModel.Meta):
        abstract = True
        verbose_name = _('respondent')
        verbose_name_plural = _('respondents')
